
package com.yixing.tech.common.base;

import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Date;
import java.util.List;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class ProvisionedAlertRule {

    private int id;
    private String uid;
    private int orgID;
    private String folderUID;
    private String ruleGroup;
    private String title;
    private String condition;
    private List<Data> data;
    private Date updated;
    private String noDataState;
    private String execErrState;
    @JsonProperty("for")
    private String forValue;
    private String provenance;
    private boolean isPaused;

    @lombok.Data
    @AllArgsConstructor
    @NoArgsConstructor
    public static class Data {

        private String refId;
        private String queryType;
        private RelativeTimeRange relativeTimeRange;
        private String datasourceUid;
        private Model model;
        @lombok.Data
        @AllArgsConstructor
        @NoArgsConstructor
        public static class RelativeTimeRange {
            private int from;
            private int to;
        }
        @lombok.Data
        @AllArgsConstructor
        @NoArgsConstructor
        public static class Model {

            private List<String> adhocFilters;
            private String alias;
            private Datasource datasource;
            private List<GroupBy> groupBy;
            private boolean hide;
            private int intervalMs;
            private String limit;
            private int maxDataPoints;
            private String measurement;
            private String orderByTime;
            private String policy;
            private String query;
            private String refId;
            private String resultFormat;
            private List<List<Select>> select;
            private String slimit;
            private List<Tags> tags;
            private String tz;
            @lombok.Data
            @AllArgsConstructor
            @NoArgsConstructor
            public static class Datasource {
                private String type;
                private String uid;
            }

            @lombok.Data
            @AllArgsConstructor
            @NoArgsConstructor
            public static class GroupBy {
                private List<String> params;
                private String type;
            }
            @lombok.Data
            @AllArgsConstructor
            @NoArgsConstructor
            public static class Select {
                private List<String> params;
                private String type;
            }
            @lombok.Data
            @AllArgsConstructor
            @NoArgsConstructor
            public static class Tags {
                private String key;
                private String operator;
                private String value;
            }


        }
    }


}
